const mysql = require('mysql');

const conn = mysql.createConnection({
  host: 'localhost',    //数据库地址
  user: 'root', //用户名
  password: 'root', //密码
  database: 'test' //数据库名
});
conn.connect();

module.exports.query = sql => {
  return new Promise((resolve, reject) => {
    conn.query(sql, (error, results, fields) => {
      if (error) {
        reject(error)
      } else {
        resolve(results)
      }
    })
  })
}
